package com.pjs.test.framework;


import static org.junit.Assert.assertNotNull;

import java.io.FileNotFoundException;

//import org.apache.log4j.BasicConfigurator;
//import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
//import org.springframework.util.Log4jConfigurer;

@RunWith(MockitoJUnitRunner.class)
public abstract class AbstractUnitTestCase<T> {
	
	protected Class<T> clazz;	
	protected T classUnderTest;	
	
	//protected static Logger log ;
	
	public AbstractUnitTestCase(final Class<T> clazz) {
		super();
		setupLogging();
		//log = Logger.getLogger(getClass());	
		this.clazz=clazz;
		buildInstance();
		
	}
	
	public void buildInstance() {
		
		try {
			classUnderTest=this.clazz.newInstance();
		} catch (Exception e) {
			classUnderTest=null;
		} 
	}
		
	@Before
	public void before(){
		//log.info(">>>>>> Starting unit test ... ");
		buildInstance();
	}
	
	@After
	public void after(){
		//log.info(" ... finishing unit test <<<<<<");
	}
	
	protected void setupLogging() {

		/*if (Logger.getRootLogger().getAppender("test")==null) {
			try {
				BasicConfigurator.resetConfiguration();
				Log4jConfigurer.initLogging("classpath:com/nomura/nest/external/test/framework/log4j.properties");				
			} catch (FileNotFoundException ex) {
				ex.printStackTrace(System.err);
			}			
			assertNotNull("Logger not created", Logger.getRootLogger().getAppender("test"));
		}		*/
	}

}

